import * as echarts from 'echarts';
import { useRef, useEffect } from 'react';

// interface MyEchartsProps {
//   option: EchartOption;
// }

let instance = null;

export default function MyEcharts (props) {

  const chartRef = useRef(null);

  useEffect(() => {
    instance = echarts.init(chartRef.current);
    // instance.setOption(props.option);
  }, []);

  useEffect(() => {
    instance.setOption(props.option);
  }, [props.option]);

  return <div className="chart" ref={ chartRef } />;
}
